Quickstart: Tabular Regression with the Python API ---------------------------------------------------- This tutorial uses :std:ref:`Energy Consumption in quickstart` provided with NeurEco installation. .. note:: The GUI functionality **Export NeurEco to Python** , see :std:ref:`Export Tabular Regression from the GUI to the Python API`, facilitates the initial transition from the usage of NeurEco with the GUI to its usage with the Python API. To work with the Tabular NeurEco models in Python, import **NeurEcoTabular** library: .. code-block:: python from NeurEco import NeurEcoTabular as Tabular Import numpy to handle the data sets: .. code-block:: python import numpy as np Load the data sets (see :std:ref:`Data preparation for NeurEco Regression python API` and :std:ref:`Energy Consumption in quickstart`): .. code-block:: python x_train = np.genfromtxt("./x_train.csv", delimiter=";", skip_header=True) y_train = np.genfromtxt("./y_train.csv", delimiter=";", skip_header=True) y_train = np.reshape(y_train, (-1, 1)) x_test = np.genfromtxt("x_test.csv", delimiter=";", skip_header=True) y_test = np.genfromtxt("y_test.csv", delimiter=";", skip_header=True) y_test = np.reshape(y_test, (-1, 1)) To initialize a NeurEco object to handle the **Regression** problem: .. code-block:: python regression_model = Tabular.Regressor() To build the model, call method **build** with the parameters set for the problem under consideration (see :std:ref:`Build NeurEco Regression model with the Python API`): .. code-block:: python regression_model.build(input_data=x_train, output_data=y_train, # the rest of these parameters are optional write_model_to="./EnergyConsumptionModel/EnergyConsumption.ednn", checkpoint_address="./EnergyConsumptionModel/EnergyConsumption.checkpoint", valid_percentage=33.33, inputs_shifting="min_centered", inputs_scaling="max_centered") .. note:: For detailed documentation on **build**, see :std:ref:`Build NeurEco Regression model with the Python API` To evaluate the NeurEco Model on the testing data, call **evaluate** method: .. code-block:: python neureco_test_outputs = regression_model.evaluate(x_test) .. note:: For detailed documentation on **evaluate**, see :std:ref:`Evaluate NeurEco Regression model with the Python API` To export the model to the chosen format, run one of the following commands: .. code-block:: python regression_model.export_c("./EnergyConsumptionModel/EnergyConsumption.h", precision="double") regression_model.export_onnx("./EnergyConsumptionModel/EnergyConsumption.onnx", precision="float16") regression_model.export_fmu("./EnergyConsumptionModel/EnergyConsumption.fmu") regression_model.export_vba("./EnergyConsumptionModel/EnergyConsumption.bas", precision="float") Export to these formats requires *embed* license. .. note:: For detailed documentation on **export**, see :std:ref:`Export NeurEco Regression model with the Python API` When the model is not needed any more, delete it from the memory: .. code-block:: python regression_model.delete() .. note:: For detailed documentation on Tabular Regression with the python API, see :std:ref:`Tabular Regression with the Python API`.